<template>
  <div id="reward">
    <div class="download-xlxs">
        <el-button type="primary" @click="collocation_query">导出</el-button>
    </div>
    <el-tabs v-model="activeName" @tab-click="changeTab">
        <el-tab-pane label="待托管" name="first">
            <listwait
            :data="collocation"
            :showUserAccoun="showUserAccoun"
            :follow="follow"
            :reasonArr="reasonArr"
            :specialist="specialist"
            @setNotShow = "setNotShow"
            @setInterior = "setInterior"
            @showLogFn = "showLogFn"
            @query = "collocation_query"
            @changeReason="changeReason"
            @changePage="collocation_query"
            @followShowFn="followShowFn"
            @changeSpecialistName = "changeSpecialistName"
            @getUserInfo="getUserInfo"
            @keepLive="keepLive"
            ></listwait>
        </el-tab-pane>
        <el-tab-pane label="进行中" name="second">
            <listbid
            :data="underway"
            :showUserAccoun="showUserAccoun"
            :showApplyCount="showApplyCount"
            :specialist="specialist"
            :follow="follow"
            @query = "queryForUnderway"
            @closeProjectFn = "closeProjectFn"
            @setNotShow = "setNotShow"
            @setInterior = "setInterior"
            @showLogFn = "showLogFn"
            @changePage="queryForUnderway"
            @followShowFn="followShowFn"
            @getSchemeList="getSchemeList"
            @changeSpecialistName = "changeSpecialistName"
            @getUserInfo="getUserInfo"
            @keepLive="keepLive"
            ></listbid>
        </el-tab-pane>
        <el-tab-pane label="已完成" name="third">
            <listdone
            :data="completed"
            :showUserAccoun="showUserAccoun"
            :showApplyCount="showApplyCount"
            :showbountyWinner="showbountyWinner"
            :follow="follow"
            @query="queryForCompleted"
            @close="close"
            @showLogFn = "showLogFn"
            @changePage="queryForCompleted"
            @followShowFn="followShowFn"
            @getSchemeList="getSchemeList"
            @getUserInfo="getUserInfo"
            @keepLive="keepLive"
            ></listdone>
        </el-tab-pane>
        <el-tab-pane label="全部" name="fourth">
            <listall
            :data="all"
            :showUserAccoun="showUserAccoun"
            :showApplyCount="showApplyCount"
            :showbountyWinner="showbountyWinner"
            :specialist="specialist"
            @changePage="queryForAll"
            @query="queryForAll"
            @getSchemeList="getSchemeList"
            @getUserInfo="getUserInfo"
            @keepLive="keepLive"
            >
            </listall>
        </el-tab-pane>
        </el-tabs>
        <!-- 跟进记录弹窗 <-->
        <el-dialog
            title="跟进记录管理"
            :visible.sync="follow.show"
            @close = "closeFollow"
        >
            <div v-show = "!follow.showSetFollowLog">
                <div class="text-right">
                    <el-button @click = "follow.showSetFollowLog = true">新增跟进记录</el-button>
                </div>
                <el-table :data="follow.list" border row-class-name="text-center" class="user-table mt-20" >
                    <el-table-column label="跟进人" :show-overflow-tooltip = "true" prop="managerName">
                    </el-table-column>
                    <el-table-column label="跟进日期" :show-overflow-tooltip = "true" prop="followUpTime">
                    </el-table-column>
                    <el-table-column label="跟进阶段" :show-overflow-tooltip = "true" prop="workStage">
                    </el-table-column>
                    <el-table-column label="跟进主题" :show-overflow-tooltip = "true" prop="title">
                    </el-table-column>
                    <el-table-column label="跟进内容" :show-overflow-tooltip = "true" prop="content">
                    </el-table-column>
                </el-table>
                <div class="pagination-wrapper clearfix" v-if="collocation.totalPage>1">
                    <div class="fr mt-15">
                        <!-- <span class="page-num font-14">
                            总数：<span v-text="collocation.totalCount"></span> 每页显示 <span v-text="collocation.pageSize"></span>  条 共 <span v-text="collocation.totalPage"></span> 页
                        </span> -->
                        <el-pagination class="fr" @current-change="followShowFn" :current-page="follow.currentPage" :page-size="follow.pageSize" layout="prev, pager, next" :total="follow.totalCount">
                        </el-pagination>
                    </div>
                </div>
                <div class="text-right mt-25">
                    <el-button @click="follow.show = false">关闭</el-button>
                </div>
            </div>
            <div v-show = "follow.showSetFollowLog">
                <el-form :model="follow" :rules="followRules" ref="follow">
                    <el-row>
                        <el-col :span = "12">
                            <el-form-item label="跟进人" prop="name" class="ml-14">
                                <el-input v-model="follow.name"></el-input >
                            </el-form-item>
                            <el-form-item label="跟进阶段" prop="stage" class="mt-20">
                                <el-input  v-model="follow.stage" ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span = "12">
                            <el-form-item label="跟进时间" prop="followUpTime">
                                <el-date-picker
                                type="date"
                                format="yyyy-MM-dd"
                                placeholder="选择日期"
                                :default-value = "new Date()"
                                v-model="follow.followUpTime"
                                >
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item label="跟进主题" prop="title" class="mt-20">
                                <el-input  placeholder="请输入主题" v-model = "follow.title"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item label="跟进内容" prop="textarea">
                        <el-input
                            :maxlength = "300"
                            :minlength = "10"
                            type="textarea"
                            :rows="4"
                            placeholder="请输入内容,最多300字"
                            v-model="follow.textarea">
                        </el-input>
                    </el-form-item>
                </el-form>
                <div class="text-right mt-20">
                    <el-button @click = "closeFollow">取消</el-button>
                    <el-button @click = "saveFollowLog('follow')" type="primary">保存</el-button>
                </div>
            </div>
        </el-dialog>
        <!-- 发布人信息弹窗 -->
        <el-dialog
            :title="showUserAccoun.title"
            :visible.sync="showUserAccoun.show"
        >
            <el-row>
                <el-col :span = "12">
                    <p>昵称：{{showUserAccoun.data.nickname}}</p>
                    <p class="mt-10">真实名称：{{showUserAccoun.data.name}}</p class="mt-10">
                    <p class="mt-10">联系电话：{{showUserAccoun.data.mobile}}</p class="mt-10">
                    <p class="mt-10">电子邮箱：{{showUserAccoun.data.email}}</p>
                </el-col>
                <el-col :span = "12">
                    <p>注册日期：2015-05-21</p>
                    <p class="mt-10">账号状态：{{accountStatus(showUserAccoun.data.status)}}</p>
                    <p class="mt-10">认证状态：{{certificationStatus(showUserAccoun.data.certificationStatus)}}</p>
                    <p class="mt-10">信用等级：{{showUserAccoun.data.creditScore}}</p>
                </el-col>
            </el-row>
            <div class="text-center mt-50 text-right">
                    <el-button @click="showUserAccoun.show = false">关闭</el-button>
            </div>
        </el-dialog>
        <!-- 报名信息 -->
        <el-dialog
            title="报名信息"
            size="large"
            :visible.sync="showApplyCount.show"
            @open = "getSchemeList"
        >
            <el-table :data="showApplyCount.list" border row-class-name="text-center" max-height="400" class="user-table mt-20" >
                    <el-table-column label="昵称" :show-overflow-tooltip = "true" prop="userAccountNickname">
                    </el-table-column>
                    <el-table-column label="姓名" :show-overflow-tooltip = "true" prop="userAccountNickname">
                    </el-table-column>
                    <el-table-column label="联系方式" :show-overflow-tooltip = "true" prop="mobile">
                    </el-table-column>
                    <el-table-column label="报名时间" :show-overflow-tooltip = "true" prop="createdAt">
                    </el-table-column>
                    <el-table-column label="方案数" :show-overflow-tooltip = "true" prop="schemeCount">
                    </el-table-column>
                    <el-table-column label="提交时间" :show-overflow-tooltip = "true" prop="schemeCreatedAt">
                    </el-table-column>
                    <el-table-column label="发包方决策" :show-overflow-tooltip = "true">
                        <template scope="scope">
                            <span>{{employerIntention(scope.row.employerIntention)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="决策描述" :show-overflow-tooltip = "true">
                        <template scope="scope">
                            <span>{{employerIntention(scope.row.employerIntention)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" :show-overflow-tooltip = "true" prop="publishTime">
                        <template scope="scope" >
                            <span @click="showCaseDetail"  class="color02 pointer">查看方案详情</span>
                        </template>
                    </el-table-column>
            </el-table>
            <div class="pagination-wrapper clearfix" v-if="showApplyCount.totalPage>1">
                <div class="fr mt-15">
                    <!-- <span class="page-num font-14">
                        总数：<span v-text="showApplyCount.totalCount"></span> 每页显示 <span v-text="showApplyCount.pageSize"></span>  条 共 <span v-text="showApplyCount.totalPage"></span> 页
                    </span> -->
                    <el-pagination class="fr" @current-change="getSchemeList" :current-page="showApplyCount.currentPage" :page-size="showApplyCount.pageSize" layout="prev, pager, next" :total="showApplyCount.totalCount">
                    </el-pagination>
                </div>
            </div>
        </el-dialog>
        <!-- 竞标方案详情 -->
        <el-dialog
            title="竞标方案详情"
            :visible.sync="caseDetail.show"
        >
            <el-row>
                <el-col :span="3">方案描述: </el-col>
                <el-col :span="21">
                   {{caseDetail.data.description}}
                </el-col>
            </el-row>
            <el-row class="mt-10">
                <el-col :span="3">Git地址：</el-col>
                <el-col :span="21"> {{caseDetail.data.codeUrl}}</el-col>
            </el-row>
            <el-row class="mt-10">
                <el-col :span="3">附件：</el-col>
                <el-col :span="21">
                    <span v-for="item in caseDetail.data.attachmentList"><a :href="item.path">{{item.name}}</a></span>
                </el-col>
            </el-row>
            <div class="text-center mt-35 text-right" @click="caseDetail.show = false">
                <el-button>
                    关闭
                </el-button>
            </div>
        </el-dialog>
        <!-- 操作记录 -->
        <el-dialog
            title="操作记录" size="large"
            :visible.sync="showLog.show"
        >
            <el-table :data="showLog.list" border row-class-name="text-center" max-height="400" class="user-table mt-20" >
                    <el-table-column label="操作人" :show-overflow-tooltip = "true" prop="managerName">
                    </el-table-column>
                    <el-table-column label="操作时间" :show-overflow-tooltip = "true" prop="createdAt">
                    </el-table-column>
                    <el-table-column label="操作主题" :show-overflow-tooltip = "true" prop="title">
                    </el-table-column>
                    <el-table-column label="操作内容" :show-overflow-tooltip = "true" prop="content">
                    </el-table-column>
            </el-table>
            <div class="pagination-wrapper clearfix handle-log" v-if="collocation.totalPage>1">
                    <div class="fr mt-15">
                         <span class="page-num font-14">
                            总数：<span v-text="showLog.totalCount"></span> 每页显示 <span v-text="showLog.pageSize"></span>  条 共 <span v-text="showLog.totalPage"></span> 页
                        </span> 
                        <el-pagination class="fr" @current-change="showLogFn()" :current-page="showLog.currentPage" :page-size="showLog.pageSize" layout="prev, pager, next" :total="showLog.totalCount">
                        </el-pagination>
                    </div>
            </div>
            <div class="mt-35 text-right">
                <el-button @click="showLog.show = false">关闭</el-button>
            </div>
        </el-dialog>
        <el-dialog
            title="关闭项目"
            :visible.sync="closeProject.show"
            @close="closeDialog('closeProject')"
        >
            <el-form :model="closeProject" :rules="closeProjectRules"  ref="closeProject">
                <div class="mt-15">
                    <h3>您确定关闭项目【企业网站开发】吗？</h3>
                    <p class="mt-10">1、项目关闭后，如发包方有未使用的项目费用将会被自动退回</p>
                    <p>2、同时发包方、竞标者将会收到项目关闭通知</p>
                    <p>3、关闭后的项目将会被已入已完成类别</p>
                    <el-form-item prop = "reason">
                        <el-input
                            class="mt-15"
                            type="textarea"
                            :rows="4"
                            placeholder="请输入内容"
                            v-model="closeProject.reason">
                        </el-input>
                    </el-form-item>
                    <div class="mt-15" prop = "radio">
                        <el-radio class="radio" v-model="closeProject.radio" label="1">正常关闭</el-radio>
                        <el-radio class="radio" v-model="closeProject.radio" label="2">异常关闭</el-radio>
                    </div>
                </div>
                <div class="text-center mt-15 text-right">
                    <el-button @click="closeProject.show = false">关闭</el-button>
                    <el-button @click="toCloseProject('closeProject')" type="primary">确定</el-button>
                </div>
            </el-form>
        </el-dialog>
    </div>
</template>
<script>
import {listWaitHosting,
        listBid,
        listDone,
        allList,
        setNotHostingReason,
        setSpecialist,
        followUpLogList,
        setVisible,
        setInternalProject,
        operationLogList,
        schemeList,
        getCaseDetail,
        addFollowLog,
        getNotHostingReason,
        managerCloseProject
    } from '@/api/reward.js'
import {getUserAccountBasicInfo, getSpecialistList} from '@/api/user.js'
import listwait from './list_wait_hosting.vue'
import listbid from './list_bid.vue'
import listdone from './list_done.vue'
import listall from './list_all.vue'
export default{
    components: {
        listwait,
        listbid,
        listdone,
        listall
    },
    created () {
        let req = {
            currentPage: 1,
            pageSize: 10
        }
        listWaitHosting(req).then(data => {
            let msg = data.data.data
            this.collocation.list = msg.data
            this.collocation.currentPage = msg.currentPage
            this.collocation.pageSize = msg.pageSize
            this.collocation.totalCount = msg.totalCount
            this.collocation.totalPage = msg.totalPage
        }).catch(function (err) {
            console.log(err)
        })
        this.NotHostingReasonList()
        this.SpecialistList()
    },
    data () {
        return {
            showLog: {
                show: false,
                list: null,
                totalPage: 0,
                totalCount: 0,
                pageSize: 0,
                currentPage: 0

            },
            caseDetail: {
                show: false,
                data: {
                    codeUrl: '',
                    description: '',
                    attachmentList: ''
                }
            },
            activeName: 'first',
            // 发布人弹窗
            showUserAccoun: {
                show: false,
                title: '',
                data: {
                    nickname: '',
                    name: '',
                    mobile: '',
                    email: '',
                    creditScore: ''
                }
            },
            // 报名人弹窗
            showApplyCount: {
                show: false,
                id: '',
                list: null
            },
            // 赏金得主弹窗
            showbountyWinner: {
                show: false,
                data: {
                    nickname: '',
                    name: '',
                    mobile: '',
                    email: '',
                    creditScore: ''
                }
            },
            // 关闭项目弹窗
            closeProject: {
                show: false,
                radio: '1',
                reason: ''
            },
            closeProjectRules: {
                radio: [{required: true, message: '请选择关闭类型'}],
                reason: [{required: true, message: '请输入原因'}]
            },
            // 未托管原因列表
            reasonArr: [
                {
                    value: '1',
                    label: '不可以'
                },
                {
                    value: '2',
                    label: '可以'
                },
                {
                    value: '3',
                    label: '可以'
                }
            ],
            // page: {
            //     currentPage: 1,
            //     pageSize: 10,
            //     totalCount: 0,
            //     totalPage: 0
            // },
            // 跟进记录
            follow: {
                id: 0,
                show: false,
                showSetFollowLog: false,
                textarea: '',
                name: this.$store.getters.userName,
                title: '',
                followUpTime: '',
                stage: '',
                managerId: '',
                list: [],
                content: '',
                currentPage: 1,
                pageSize: 10,
                totalCount: 0
            },
            followRules: {
                name: [{required: true, message: '请输入名字'}],
                stage: [{required: true, message: '请输入阶段'}],
                followUpTime: [{required: true, message: '请输入时间'}],
                textarea: [{required: true, min: 10, message: '请输入内容,最少输入10个字'}],
                title: [{required: true, message: '请输入主题'}]
            },
            req: {
                currentPage: 1,
                pageSize: 10
            },
            // 代托管
            collocation: {
                list: null,
                // 悬赏编号
                rewardNo: '',
                // 悬赏名称
                name: '',
                // 发布开始时间
                publishTimeStart: '',
                // 发布结束时间
                publishTimeEnd: '',
                // 内部属性 1内部 2外部
                isInternal: {
                    value: '',
                    options: [
                        {
                            value: 1,
                            label: '内部'
                        },
                        {
                            value: 2,
                            label: '外部'
                        }
                    ]
                },
                // 当前页
                currentPage: 1,
                // 每页数据量
                pageSize: 10,
                totalCount: 0,
                totalPage: 0
            },
            // 进行中
            underway: {
                list: null,
                // 悬赏编号
                rewardNo: '',
                // 悬赏名称
                name: '',
                // 发布开始时间
                publishTimeStart: '',
                // 发布结束时间
                publishTimeEnd: '',
                // 发包性质 1内部 2外部
                isInternal: {
                    value: '',
                    options: [
                        {
                            value: 1,
                            label: '内部'
                        },
                        {
                            value: 2,
                            label: '外部'
                        }
                    ]
                },
                // 是否有人报名 1没人报名 2有人报名
                hasAnyoneApply: {
                    value: '',
                    options: [
                        {
                            value: 1,
                            label: '无人报名'
                        },
                        {
                            value: 2,
                            label: '有人报名'
                        }
                    ]
                },
                // 受理状态 1未受理 2已受理
                handleStatus: {
                    value: '',
                    options: [
                        {
                            value: 1,
                            label: '未跟进'
                        },
                        {
                            value: 2,
                            label: '已跟进'
                        }
                    ]
                },
                // 当前页
                currentPage: 1,
                // 每页数据量
                pageSize: 10
            },
            // 已完成
            completed: {
                list: null,
                // 悬赏编号
                rewardNo: '',
                // 悬赏名称
                name: '',
                // 发布开始时间
                publishTimeStart: '',
                // 发布结束时间
                publishTimeEnd: '',
                // 完成开始时间
                doneTimeStart: '',
                // 完成结束时间
                doneTimeEnd: '',
                // 内部属性 1内部 2外部
                isInternal: {
                    value: '',
                    options: [
                        {
                            value: 1,
                            label: '内部'
                        },
                        {
                            value: 2,
                            label: '外部'
                        }
                    ]
                },
                // 当前页
                currentPage: 1,
                // 每页数据量
                pageSize: 10,
                // 项目专员Id
                specialistId: {
                    value: '',
                    options: [
                        {
                            label: '刘',
                            value: 4
                        },
                        {
                            label: '宋',
                            value: 6
                        },
                        {
                            label: '陈',
                            value: 7
                        },
                        {
                            label: '张',
                            value: 8
                        }
                    ]
                },
                // 状态 4已完成 6仲裁中 7已下架 8 已关闭
                status: {
                    value: '',
                    options: [
                        {
                            label: '已完成',
                            value: 4
                        },
                        {
                            label: '仲裁中',
                            value: 6
                        },
                        {
                            label: '已下架',
                            value: 7
                        },
                        {
                            label: '已关闭',
                            value: 8
                        }
                    ]
                }
            },
            // 全部
            all: {
                list: null,
                // 悬赏编号
                rewardNo: '',
                // 悬赏名称
                name: '',
                // 发布开始时间
                publishTimeStart: '',
                // 发布结束时间
                publishTimeEnd: '',
                // 完成开始时间
                doneTimeStart: '',
                // 完成结束时间
                doneTimeEnd: '',
                // 内部属性 1内部 2外部
                isInternal: {
                    value: '',
                    options: [
                        {
                            value: 1,
                            label: '内部'
                        },
                        {
                            value: 2,
                            label: '外部'
                        }
                    ]
                },
                // 当前页
                currentPage: 1,
                // 每页数据量
                pageSize: 10,
                // 项目专员Id
                specialistId: {
                    value: '',
                    options: [
                        {
                            label: '刘',
                            value: 4
                        },
                        {
                            label: '宋',
                            value: 6
                        },
                        {
                            label: '陈',
                            value: 7
                        },
                        {
                            label: '张',
                            value: 8
                        }
                    ]
                },
                // 状态 4已完成 6仲裁中 7已下架 8 已关闭
                status: {
                    value: '',
                    options: [
                        {
                            label: '已完成',
                            value: 4
                        },
                        {
                            label: '仲裁中',
                            value: 6
                        },
                        {
                            label: '已下架',
                            value: 7
                        },
                        {
                            label: '已关闭',
                            value: 8
                        }
                    ]
                }
            },
            // alert 缺少一个项目专员接口,用数组模拟
            specialist: []
        }
    },
    methods: {
        keepLive () {
            this.$route.meta.keepAlive = true
        },
        // 关闭项目逻辑
        toCloseProject (formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    let req = {
                        radio: this.closeProject.radio,
                        reason: this.closeProject.reason
                    }
                    managerCloseProject(req).then(data => {
                        this.closeProject.show = false
                        this.$message('关闭成功')
                    })
                } else {
                    return false
                }
            })
        },
        // 请求项目专员列表
        SpecialistList () {
            getSpecialistList().then(data => {
                let msg = data.data.data
                this.specialist = msg
            })
        },
        // 请求未托管原因列表
        NotHostingReasonList () {
            getNotHostingReason().then((data) => {
                let msg = data.data.data
                let arr = []
                for (let i = 0; i < msg.length; i++) {
                    let obj = {
                        label: msg[i]
                    }
                    arr.push(obj)
                }
                this.reasonArr = arr
            })
        },
        // 发包帐户认证状态
        accountStatus (num) {
            if (num === 1) {
                return '正常'
            } else {
                return '冻结'
            }
        },
        // 关闭弹窗，充值from
        closeDialog (fromName) {
            this.resetFrom(fromName)
        },
        // 根据状态码返回认证状态
        certificationStatus (num) {
            if (num === 1) {
                return '未认证'
            } else if (num === 2) {
                return '审核中'
            } else if (num === 3) {
                return '通过'
            } else {
                return '未通过'
            }
        },
        // 获取发包，接包方信息
        getUserInfo (id, type) {
            let req = {
                id: id
            }
            getUserAccountBasicInfo(req).then(data => {
                if (data.data.code === 0) {
                    if (type === 1) {
                        this.showUserAccoun.title = '发包方信息查看'
                    } else {
                        this.showUserAccoun.title = '接包方信息查看'
                    }
                    this.showUserAccoun.data = data.data.data
                    this.showUserAccoun.show = true
                } else {
                    this.$message('信息获取失败，请稍候重试')
                }
            })
        },
        // 获取报名列表
        getSchemeList (currentPage = 1, pageSize = 10, id) {
            if (id) {
                this.showApplyCount.id = id
            }
            let req = {
                id: id,
                currentPage,
                pageSize
            }
            schemeList(req).then(data => {
                let msg = data.data
                if (msg.code === 0) {
                    this.showApplyCount.list = data.data.data.data
                    this.showApplyCount.currentPage = data.data.data.currentPage
                    this.showApplyCount.pageSize = data.data.data.pageSize
                    this.showApplyCount.totalCount = data.data.data.totalCount
                    this.showApplyCount.totalPage = data.data.data.totalPage
                }
            })
        },
        // 获取方案详情
        showCaseDetail (id) {
            let req = {
                id: id
            }
            getCaseDetail(req).then(data => {
                if (data.data.code === 0) {
                    this.caseDetail.data = data.data.data.data
                    this.caseDetail.show = true
                } else {
                    this.$message('获取报名详情失败')
                }
            })
        },
        // 改变未托管原因
        changeReason (scope, isSelect) {
            let req = {
                id: scope.row.id,
                type: scope.row.notHostingReason,
                reason: scope.row.notHostingReason
            }
            if (isSelect) {
                setNotHostingReason(req).then(data => {
                    let msg = data.data.code
                    if (msg === 0) {
                        this.$message('未托管原因设置成功')
                    } else {
                        this.$message('未托管原因设置失败，请稍候再试')
                    }
                })
            }
        },
        // 更改项目专员
        changeSpecialistName (scope, isSelect) {
            let req = {
                id: scope.row.id,
                specialistId: scope.row.specialistName
            }
            if (isSelect) {
                setSpecialist(req).then(data => {
                    let msg = data.data.code
                    if (msg === 0) {
                        this.$message('项目专员设置成功')
                    } else {
                        this.$message('项目专员设置失败，请稍候再试')
                    }
                })
            }
        },
        // 未托管列表查询
        collocation_query (currentPage = 1, pageSize = 10) {
            let req = {
                rewardNo: this.collocation.rewardNo,
                name: this.collocation.name,
                publishTimeStart: this.collocation.publishTimeStart,
                publishTimeEnd: this.collocation.publishTimeEnd,
                isInternal: this.collocation.isInternal.value,
                currentPage,
                pageSize
            }
            listWaitHosting(req).then(data => {
                let msg = data.data
                this.collocation.list = msg.data.data
            })
        },
        // 查询进行中的项目列表
        queryForUnderway (currentPage = 1, pageSize = 10) {
            let req = {
                rewardNo: this.underway.rewardNo,
                name: this.underway.name,
                publishTimeStart: this.underway.publishTimeStart,
                publishTimeEnd: this.underway.publishTimeEnd,
                isInternal: this.underway.isInternal.value,
                hasAnyoneApply: this.underway.hasAnyoneApply.value,
                handleStatus: this.underway.handleStatus.value,
                currentPage,
                pageSize
            }
            listBid(req).then(data => {
                if (data.data.code === 0) {
                    this.getData(this.underway, data)
                    this.$message('查询成功')
                } else {
                    this.$message('查询失败')
                }
            })
        },
        // 查询已完成的项目列表
        queryForCompleted (currentPage = 1, pageSize = 10) {
            let req = {
                rewardNo: this.completed.rewardNo,
                name: this.completed.name,
                publishTimeStart: this.completed.publishTimeStart,
                publishTimeEnd: this.completed.publishTimeEnd,
                doneTimeStart: this.completed.doneTimeStart,
                doneTimeEnd: this.completed.doneTimeEnd,
                isInternal: this.completed.isInternal.value,
                specialistId: this.completed.specialistId.value,
                status: this.completed.status.value,
                currentPage,
                pageSize
            }
            listDone(req).then(data => {
                if (data.data.code === 0) {
                    this.getData(this.completed, data)
                    this.$message('查询成功')
                } else {
                    this.$message('查询失败')
                }
            })
        },
        // 查询所有项目列表
        queryForAll (currentPage = 1, pageSize = 10) {
            let req = {
                rewardNo: this.all.rewardNo,
                name: this.all.name,
                publishTimeStart: this.all.publishTimeStart,
                publishTimeEnd: this.all.publishTimeEnd,
                doneTimeStart: this.all.doneTimeStart,
                doneTimeEnd: this.all.doneTimeEnd,
                isInternal: this.all.isInternal.value,
                specialistId: this.all.specialistId.value,
                status: this.all.status.value,
                currentPage,
                pageSize
            }
            allList(req).then(data => {
                if (data.data.code === 0) {
                    this.getData(this.all, data)
                    this.$message('查询成功')
                } else {
                    this.$message('查询失败')
                }
            })
        },
        // 将获取的数据转给本地对象
        getData (obj, data) {
            let msg = data.data.data
            obj.list = msg.data
            obj.currentPage = msg.currentPage
            obj.pageSize = msg.pageSize
            obj.totalCount = msg.totalCount
            obj.totalPage = msg.totalPage
        },
        // 切换tab回调,如果已请求过数据则不再请求
        changeTab (tab) {
            let req = {
                currentPage: 1,
                pageSize: 10
            }
            if (tab.index === '0') {
                !this.collocation.list && listWaitHosting(req).then(data => {
                    let msg = data.data.data
                    this.collocation.list = msg.data
                    this.collocation.currentPage = msg.currentPage
                    this.collocation.pageSize = msg.pageSize
                    this.collocation.totalCount = msg.totalCount
                    this.collocation.totalPage = msg.totalPage
                })
            } else if (tab.index === '1') {
                !this.underway.list && listBid(req).then(data => {
                    let msg = data.data.data
                    this.underway.list = msg.data
                    this.underway.currentPage = msg.currentPage
                    this.underway.pageSize = msg.pageSize
                    this.underway.totalCount = msg.totalCount
                    this.underway.totalPage = msg.totalPage
                })
            } else if (tab.index === '2') {
                !this.completed.list && listDone(req).then(data => {
                    let msg = data.data.data
                    this.completed.list = msg.data
                    this.completed.currentPage = msg.currentPage
                    this.completed.pageSize = msg.pageSize
                    this.completed.totalCount = msg.totalCount
                    this.completed.totalPage = msg.totalPage
                })
            } else if (tab.index === '3') {
                !this.all.list && allList(req).then(data => {
                    let msg = data.data.data
                    this.all.list = msg.data
                    this.all.currentPage = msg.currentPage
                    this.all.pageSize = msg.pageSize
                    this.all.totalCount = msg.totalCount
                    this.all.totalPage = msg.totalPage
                })
            }
        },
        // 操作记录
        showLogFn (currentPage = 1, pageSize = 10, id = this.showLog.id) {
            if (id) {
                this.showLog.id = id
                let req = {
                    id: id,
                    currentPage,
                    pageSize
                }
                operationLogList(req).then(data => {
                    let msg = data.data
                    if (msg.code === 0) {
                        this.showLog.list = msg.data.data
                        this.showLog.currentPage = msg.data.currentPage
                        this.showLog.pageSize = msg.data.pageSize
                        this.showLog.totalCount = msg.data.totalCount
                        this.showLog.totalPage = msg.data.totalPage
                        this.showLog.show = true
                    } else {
                        this.$message('获取操作记录失败')
                    }
                }).catch(function (err) {
                    console.log(err)
                })
            }
        },
        // 保存跟进记录
        saveFollowLog (formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    let req = {
                        id: this.follow.id,
                        managerId: 1, // TODO: 需要对接用户登录接口
                        followUpTime: this.follow.followUpTime.toLocaleDateString(),
                        workStage: this.follow.stage,
                        title: this.follow.title,
                        content: this.follow.textarea
                    }
                    addFollowLog(req).then(data => {
                        let d = data.data
                        if (d.code !== 0) {
                            this.$message(d.message)
                            return
                        }
                        this.$message('记录已保存')
                        this.follow.showSetFollowLog = false
                        this.resetFrom(formName)
                        this.followShowFn()
                    })
                } else {
                    return false
                }
            })
        },
        // 重置跟进记录表单
        resetFrom (formName) {
            this.$refs[formName].resetFields()
            this.follow.showSetFollowLog = false
        },
        // 关闭跟进记录
        closeFollow () {
            this.resetFrom('follow')
            this.follow.showSetFollowLog = false
        },
        // 跟进记录
        followShowFn (currentPage = 1, pageSize = 10, id = this.follow.id) {
            if (id) {
                this.follow.id = id
            }
            let req = {
                id: this.follow.id,
                currentPage,
                pageSize
            }
            followUpLogList(req).then(data => {
                let msg = data.data
                if (msg.code === 0) {
                    this.follow.list = msg.data.data
                    this.follow.currentPage = msg.data.currentPage
                    this.follow.pageSize = msg.data.pageSize
                    this.follow.totalCount = msg.data.totalCount
                    this.follow.totalPage = msg.data.totalPage
                    this.follow.show = true
                    this.follow.stage = this.follow.list.length > 0 ? this.follow.list[this.follow.list.length - 1].workStage : '待托管'
                } else {
                    this.$message('获取跟进记录失败')
                }
            }).catch(function (err) {
                console.log(err)
            })
        },
        // 设置为主站不显示
        setNotShow (id) {
            this.$confirm('您确定将项目【企业网站开发】设置为主站不显示吗？', '设置主站显示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let req = {
                    id: id,
                    visible: 2
                }
                setVisible(req).then(data => {
                    let msg = data.data
                    if (msg.code === 0) {
                        this.$message({
                            type: 'success',
                            message: '设置成功'
                        })
                    } else {
                        this.$message({
                            type: 'error',
                            message: '设置失败'
                        })
                    }
                })
            }).catch(() => {
            })
        },
        // 报名列表-根据状态码返回状态
        employerIntention (num) {
            if (num === 1) {
                return '默认'
            } else if (num === 2) {
                return '倾向的'
            } else {
                return '拒绝的'
            }
        },
        // 设为内部项目
        setInterior (id, scope) {
            this.$confirm('您确定将项目【企业网站开发】设置为内部项目吗？', '设置内部项目', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let req = {
                    id: id,
                    isInternal: 2
                }
                setInternalProject(req).then(data => {
                    let msg = data.data
                    if (msg.code === 0) {
                        scope.row.isInternal = 1
                        this.$message({
                            type: 'success',
                            message: '设置成功'
                        })
                    } else {
                        this.$message({
                            type: 'success',
                            message: '设置失败'
                        })
                    }
                })
            }).catch(() => {
            })
        },
        // 查看关闭项目原因
        close (text) {
            this.$confirm(text, '悬赏关闭原因', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            })
        },
        // 切换显示关闭项目弹窗
        closeProjectFn () {
            this.closeProject.show = !this.closeProject.show
        }
    },
    beforeRouteLeave (to, from, next) {
        if (to.path !== '/project/caseDetail') {
            this.$route.meta.keepAlive = false
            next()
        } else {
            next()
        }
    }
}
</script>
<style scoped>
    .lh35{
        line-height: 35px;
        line-height: 35px/9;
    }
    .menu-center{
        position: relative;
        top:8px;
    }
    .download-xlxs{
        position:absolute;
        right: 14px;
        z-index: 1
    }
    .ml-14{
        margin-left: 14px
    }
</style>
